<%@language=vbscript%>
<%
	Session("bChucnang")=4
	Session("FormName")="F20"
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file="..\RootContent.inc"-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>VĂN THƯ ĐI</title>
</head>
<%	chuyendi=request("chuyendi")
	backform=request("backform")+1
	bDangky=Request("bDangky")
	Dim Msg
	bComm=Request("bComm")	
	bPhanLoai=Request("ComboPhanloai")
	maflow=request("maflow")
	if bComm="edit" then
		bOutnum=Request("TxtOutNum")
		bOutSymbol=Request("TxtOutSymbol")
		bSoghinhan=trim(bOutnum) & "/" & trim(bOutSymbol)
		'bSoghinhan=Request("TxtSoghinhan")
		bID=Request("TxtID")
		sSQL="Select * from VTDi Where ID Like '"& bID &"'"
		Set RecT=Server.CreateObject("ADODB.Recordset")
		RecT.CursorType=3
		RecT.CacheSize=5
		RecT.Open sSQL,Conn
		Dim bDisplay
		bDisplay=False
		if RecT.RecordCount>0 then
			dim bSoghinhan
			Dim bID
			Dim bSogoccu
			Session("bMaVBDi")=RecT("ID")	
			Session("bTenVBDi")=RecT("Trichyeu")		
			bSoghinhan=trim(RecT("soghinhan"))
			bOutNum=cstr(RecT("so"))
			bOutnumcu=bOutNum
			bOutSymbol=right(bSoghinhan,len(bSoghinhan)-len(bOutNum)-1)
			bID=RecT("ID")		
			bSoghinhancu=RecT("soghinhan")			
			bIDcu=RecT("ID")		
			bTrichyeu=RecT("Trichyeu")
			bTomtat=RecT("Tomtat")
			bTinhchat=RecT("Tinhchat")
			bTinhchat1=RecT("Tinhchat1")
			bTentep=RecT("Tentep")
			bTentepcu=RecT("Tentep")
			bNguoiky=RecT("Nguoiky")
			bNGayky=RecT("Ngayky")
			bNGaydi=RecT("Ngaydi")
			bNam=year(RecT("Ngaydi"))
			bNamcu=year(RecT("Ngaydi"))
			bNguoinhan=RecT("Nguoinhan")
			bTukhoa=RecT("Tukhoa")
			bReadwrite=RecT("congcong")
			bCongcong=RecT("congcong")
			bTTDuyet=RecT("trangthaiduyet")
			bDiachiluutru=RecT("diachiluutru")
			bPhanloai=RecT("phanLoai")
			bPhanloaicu=RecT("Phanloai")
			bSoban=RecT("Soban")
			bSoto=RecT("Soto")
			bSLNoidung=RecT("Soluongnoidung")
			bNoinhan=RecT("Noinhan")
			bDisplay=true
			bBaocao=Rect("Baocao")
			bSelect1=rect("DVSoan")
			bSelect2=rect("noinhan")
		end if
	end if
	Dim bTonTai
	Select case bComm
		case "okedit"
			bOutnum=Request("TxtOutNum")			
			bOutSymbol=Request("TxtOutSymbol")
			bTrichyeu=Request("TxtTrichyeu")
			bTomtat=Request("TxtTomtat")
			bTinhchat=Request("ComboTinhchat")
			bTinhchat1=Request("ComboTinhchat1")
			bTentep=Request("TxtTentep")
			bNguoiky=trim(Request("TxtNguoiky"))
			bNGayky=request("TxtNgayky")
			bNGaydi=request("TxtNgaydi")
			bNam=year(request("TxtNgaydi"))
					
			bNguoinhan=Request("TxtNguoinhan")
			bTukhoa=Request("TxtTukhoa")
			bReadwrite=Request("bReadwrite")
			bnoinhan=Request("TxtNoinhan")
			bSelect1=Request("Select1")
			bSelect2=Request("Select2")
			if bReadwrite then
				bReadwrite=1
			else
				bReadwrite=0
			end if
			bCongcong=Request("congcong")
			if bCongcong then
				bCongcong=1
			else
				bCongcong=0
			end if
			bBaocao=Request("ChkBC")
			if bBaocao then	
				bBaocao=1
			else
				bBaocao=0
			end if
			bSoghinhancu=Request("bSoghinhancu")
			bIDcu=Request("bIDcu")
			bNamcu=request("bNamcu")
			bOutnumcu=request("bOutnumcu")
			bPhanloaicu=request("bPhanloaicu")
'			bDiachiluuTru=Request("Txtdiachiluutru")
			bDiachiluutru=0
			bPhanloai=Request("ComboPhanloai")
			bNhomCV=Request("ComboNhomCV")
			bNhomCVCU=Request("bNhomCVcu")
			bTTDuyet=Request("bTTDuyet")
			bSoban=Request("TxtSoban")
			bSoto=Request("TxtSoto")
			if bTTDuyet then
				bTTDuyet=1
			else
				bTTDuyet=0
			end if
			bSLNoidung=Request("TxtSLNoidung")
			if Request("filename")<>"" then
				bTentepcu=Request("filename")
			end if
			bSoghinhan=bOutnum+"/"+bOutSymbol
			Temp=bSoghinhan			
			bNguoiduyet=Session("bMaCB")
			bNgayky=SaveDate(bNgayky)
			bNgaydi=SaveDate(bNgaydi)
			On Error resume next
			Conn.BeginTrans
			if (trim(CSTR(boutnum)=trim(CSTR(boutnumcu))))  and (trim(CSTR(bNamcu))=trim(CSTR(bnam))) and (bPhanloaicu=bPhanloai) then
				bID="DI"+cstr(bNam)+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)
				bTentep=bID+".VT"
				sSQL="Update VTdi set ID='"& bID &"',Soghinhan='"& bSoghinhan &"', ngaydi='"& bNgaydi &"', ngayky='"& bNgayky _
					&"',Nguoiky='"& ModiString(bNguoiky) _
					&"',Tomtat='"& ModiString(trim(bTomtat)) &"',Trichyeu='"& ModiString(bTrichyeu) &"',Tukhoa='"& ModiString(bTukhoa) _
					&"',Nguoinhan='"& ModiString(bNguoinhan) _
					&"',Tinhchat='"& ModiString(bTinhchat) _
					&"',phanLoai="& bPhanloai _
					&",Tentep='"& ModiString(bTentep) _
					&"',Soban='"& ModiString(bSoban) _
					&"',Soto='"& ModiString(bSoto) _
					&"',diachiluutru="& bDiachiluutru _
					&",Congcong="& bReadwrite _
					&",trangthaiduyet="& bTTDuyet _
					&",Nguoiduyet='"& bNguoiduyet _
					&"',noinhan='"& bSelect2 _
					&"',DVSoan='"& bSelect1 _
					&"',Baocao="& bBaocao _
					&" Where ID ='"& bIDcu &"'" 
				Conn.Execute sSQL

				'Msg="N&#7897;i dung &#273;&#227; &#273;&#432;&#7907;c s&#7917;a"
				bComm="edit"
			end if
			if (trim(cstr(bOutnum)<>trim(cstr(bOutnumcu))))  and (trim(bNamcu)=trim(bnam)) and (bPhanloaicu=bPhanloai) then
				bID="DI"+cstr(bNam)+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)
				bTentep=bID+".VT"
				Temp=bID
				if KTSoghinhan(bOutnum,bPhanloai,bNam,"okedit") then
					Msg="M&#227; s&#7889; ghi nh&#7853;n &#273;&#227; t&#7891;n t&#7841;i"
					bTontai=True
					bDisplay=true
					bComm="edit"
					bIDcu=request("bIDcu")
					bNamcu=request("bNamcu")
					bPhanloaicu=request("bPhanloaicu")
					bNhomCVCu=request("bNhomCVcu")
					bOutnumcu=request("bOutnumcu")
					bSoghinhancu=request("bSoghinhancu")
					bOutnum=bOutnumcu
					bID=bIDcu
				else
					'Msg="N&#7897;i dung &#273;&#227; &#273;&#432;&#7907;c s&#7917;a"
					bTonTai=false
					bComm="edit"					
				end if	
				if not bTontai then
					sSQL="Update VTDi set so="& bOutnum &" ,ID='"& ModiString(bID)&"',Soghinhan='"& ModiString(bSoghinhan) _
						&"', ngaydi='"& bNgaydi &"',ngayky='"& bNgayky _
						&"',Nguoiky='"& ModiString(bNguoiky) _
						&"',Tomtat='"& ModiString(trim(bTomtat)) &"',Trichyeu='"& ModiString(bTrichyeu) &"',Tukhoa='"& ModiString(bTukhoa) _
						&"',Nguoinhan='"& ModiString(bNguoinhan) _
						&"',Tinhchat='"& ModiString(bTinhchat) _
						&"',Soto='"& ModiString(bSoto) _
						&"',Soban='"& ModiString(bSoban) _
						&"',Phanloai="& bPhanloai _
						&",Tentep='"& ModiString(bTentep) _
						&"',diachiluutru="& bDiachiluutru _
						&",Congcong="& bReadwrite _
						&",trangthaiduyet="& bTTDuyet _
						&",Nguoiduyet='"& bNguoiduyet _
						&"',noinhan='"& bSelect2 _
						&"',DVSoan='"& bSelect1 _
						&"',Baocao="& bBaocao _
						&" Where ID ='"& bIDcu &"'" 
						Conn.Execute sSQL			
					bSoghinhancu=bSoghinhan
					bUpdate=true			
				end if
			end if
			if  (trim(cstr(bNamcu))<>trim(cstr(bnam))) or (bPhanloaicu<>bPhanloai) then
				sSQL="Select * from VTDi where year(ngaydi)='"& bNam &"' and phanloai="& bPhanloai &"  order by so"
				Set RecTD=server.createobject("ADODB.Recordset")
				RecTD.cursorType=3
				RecTD.Cachesize=5
				RecTD.open sSQL,Conn					
				if (not RecTD.EOF) and (not RecTD.BOF) then
					RecTD.MOvelast
					bOutnum=cstr(clng(RecTD("so"))+1)												
				else
					bOutnum="1"
				end if
				RecTD.close
				Set RecTD=nothing
				bSoghinhan=bOutNum+"/"+bOutSymbol
				Temp=bSoghinhan
				bID="DI"+cstr(bNam)+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)
				bTentep=bID+".VT"
				sSQL="Update VTDi set so="& bOutnum &" ,ID='"& ModiString(bID) &"',Soghinhan='"& ModiString(bSoghinhan) _
						&"', ngaydi='"& bNgaydi &"',ngayky='"& bNgayky _
						&"',Nguoiky='"& ModiString(bNguoiky) _
						&"',Tomtat='"& ModiString(trim(bTomtat)) &"',Trichyeu='"& ModiString(bTrichyeu) &"',Tukhoa='"& ModiString(bTukhoa) _
						&"',Nguoinhan='"& ModiString(bNguoinhan) _
						&"',Tinhchat='"& ModiString(bTinhchat) _
						&"',soban='"& ModiString(bSoban) _
						&"',Soto='"& ModiString(bSoto) _
						&"',Phanloai="& bPhanloai _
						&",Tentep='"& ModiString(bTentep) _
						&"',diachiluutru="& bDiachiluutru _
						&",Congcong="& bReadwrite _
						&",trangthaiduyet="& bTTDuyet _
						&",Nguoiduyet='"& bNguoiduyet _
						&"',noinhan='"& bSelect2 _
						&"',DVSoan='"& bSelect1 _
						&"',Baocao="& bBaocao _
						&" Where ID ='"& bIDcu &"'" 
						Conn.Execute sSQL
				'Msg="N&#7897;i dung &#273;&#227; &#273;&#432;&#7907;c s&#7917;a"
				bComm="edit"
				bUpdate=true
			end if
			%><%=Err.description%><%		
			Conn.Execute sSQL
			if bUpdate then
				sSQL="Update Muontra set BophanQL="& bDiachiluutru &",matailieu = '"& ModiString(bID) &"' where matailieu like '"& bIDcu &"' and Loaitailieu=2"
				Conn.Execute sSQL 
				sSQL="Update vanban_noidung set mavanthu='"& ModiString(bID) &"' where mavanthu Like '"& bIDcu &"' and loaivanthu='2'" 				
				Conn.Execute sSQL
				sSQL="Update Quyen set mavanthu='"& ModiString(bID) &"' where mavanthu Like '"& bIDcu &"' and maloaivanthu='2'" 				
				Conn.Execute sSQL
				sSQL="Update Quyen_nhom set mavanthu='"& ModiString(bID) &"' where mavanthu Like '"& bIDcu &"' and maloaivanthu='2'" 				
				Conn.Execute sSQL				
				'Sua File
				set TextFile=server.CreateObject("Activefile.file")
				PathOld=RootContent & "Upload\"& cstr(bNamcu) &"\Di\Text"
				PathOld=Pathold & "\" & bIDcu & ".VT" 
				Path=RootContent & "Upload\"& cstr(bNam) &"\Di\Text"
				Path=Path & "\" & bID & ".VT"
				'Tao thu muc nam moi
				Set bDir=server.CreateObject("ActiveFile.Directory")
		     	bPathFolder=RootContent & "Upload"& "\" & bNam
		          bDir.Path=bPathFolder
    				if not bDir.Exists() then
    				   	call bDir.Create(bPathFolder)
    				end if
	    			bPathFolder=bPathFolder & "\Di"
				bDir.Path=bPathFolder
	     		if not bDir.Exists() then
					Call bDir.Create(bPathFolder)
				end if
				bPathFolder=bPathFolder & "\Text"
			    	bDir.Path=bPathFolder
				if not bDir.Exists() then
	   				Call bDir.Create(bPathFolder)
				end if
			     Set bDir=nothing		          							
				TextFile.Name=Path
				if TextFile.Exists() then
					TextFile.Delete()
				end if				
				TextFile.Name=PathOld	
				if TextFile.Exists() then
					Call TextFile.Copy (Path)				
				end if
				TextFile.Name=PathOld				
				if TextFile.Exists() then
					TextFile.Delete()
				end if
				sSQL="Select * from vanban_noidung where mavanthu Like '"& ModiString(bID) &"' and Loaivanthu='2'  order by Sothutu"			
				Set RecRename=server.CreateObject("ADODB.Recordset")
				RecRename.CursorType=3
				RecRename.CacheSize=5
				RecRename.Open sSQL,Conn
				Set Ex=server.CreateObject("Vinalines.ClsFile")
				Do while not RecRename.EOF					
					Pathold=RootContent & "Upload\"& Cstr(bNamcu) &"\Di"
					Pathold=Pathold & "\" & bIDcu & "S" & trim(cstr(RecRename("sothutu"))) & "." & Ex.GetExtensionFile(RecRename("Tentep"))			
					Path=RootContent & "Upload\"& Cstr(bNam) &"\DI"
					Path=Path & "\" & bID & "S" & trim(cstr(RecRename("sothutu"))) & "." & Ex.GetExtensionFile(RecRename("Tentep"))			
					TextFile.Name=Path
					if TextFile.Exists() then
						TextFile.delete()
					end if
					TextFile.Name=PathOld
					if TextFile.Exists() then
						call TextFile.Copy (Path)
						TextFile.Delete()
					end if
					bName=bID & "S" & trim(cstr(RecRename("sothutu"))) & "." & Ex.GetExtensionFile(RecRename("Tentep"))
					sSQL="Update vanban_noidung set Tentep='"& bName &"' where loaivanthu='2' and  Sothutu="& RecRename("sothutu") &" And mavanthu like '"& ModiString(bID) &"'"
					Conn.Execute sSQL				
					RecRename.MoveNext
				Loop
				%><%=Err.Description%><%
				RecRename.Close
				set RecRename=nothing
				set TextFile=nothing
				set Ex=nothing
				if bReadwrite then
					sSQL="Delete Quyen where maloaivanthu='2' and mavanthu like '"& ModiString(bID) &"'"
					Conn.Execute sSQL
					sSQL="Delete Quyen_nhom where maloaivanthu='2' and mavanthu like '"& ModiString(bID) &"'"
					Conn.Execute sSQL
				end if
			End if
			'Ket Thuc Transaction
			if Err.number=0 then
				if Session("VanBan")="" then 
					Session("VanBan")="-" & Session("VanBan") & modistring(bID) & "-"
				else
					Session("VanBan")=Session("VanBan") & modistring(bID) & "-"
				end if
				Conn.CommitTrans
				btrangthai=1
			else
				Conn.RollbackTrans
				bTrangthai=0
			end if
			'Ghi nhan Ai da login thanh cong				
			bHoten=Session("bHoten")
			bNgaygio=cstr(Date()) &" "& cstr(Time())
			bChucnang="C&#7853;p nh&#7853;t V&#259;n th&#432; quyết định"
			bIDTailieu=bSoghinhan
			bDongtac="S&#7917;a"
			sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
				&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"',"& bTrangthai &")"
			Conn.Execute sSQL	
			
			bIDcu=bID
			bNamcu=bNam
			bPhanloaicu=bPhanloai
			bNhomCVcu=bNhomCV
			bOutnumcu=bOutnum
			Session("bMaVBQD")=bID
			Session("bTenVBQD")=bTrichyeu			
		case "okadd"
			bOutnum=Request("TxtOutNum")
			bOutSymbol=Request("TxtOutSymbol")
			bTrichyeu=Request("TxtTrichyeu")
			bTomtat=Request("TxtTomtat")
			bTinhchat=Request("ComboTinhchat")
			bTinhchat1=Request("ComboTinhchat1")
			bSoban=Request("TxtSoban")
			bSoto=Request("TxtSoto")
			bTentep=Request("TxtTentep")
			bNguoiky=trim(Request("TxtNguoiky"))
			bNgayky=request("TxtNgayky")
			bNgaydi=request("TxtNgaydi")
			bNam=year(Request("TxtNgaydi"))
			bNoinhan=request("TxtNoinhan")
			bNguoinhan=Request("TxtNguoinhan")
			bTukhoa=Request("TxtTukhoa")
			bReadwrite=Request("bReadwrite")			
			bSelect1=Request("Select1")
			bSelect2=Request("Select2")
			if bReadwrite then
				bReadwrite=1
			else
				bReadwrite=0
			end if
			bCongcong=Request("congcong")
			if bCongcong then
				bCongcong=1
			else
				bCongcong=0
			end if
			bBaocao=Request("ChkBC")
			if bBaocao then	
				bBaocao=1
			else
				bBaocao=0
			end if
'			bDiachiluutru=request("Txtdiachiluutru")
			bDiachiluutru=0
			bPhanloai=Request("ComboPhanloai")
			bNhomCV=Request("ComboNhomCV")
			bTTDuyet=Request("bTTDuyet")
			if bTTDuyet then
				bTTDuyet=1
			else
				bTTDuyet=0
			end if
			bNoigui=Request("TxtNoigui")
			bSLNoidung=Request("TxtSLNoidung")
			if KTSoghinhan(bOutnum,bPhanloai,bNam,"okadd") then
				sSQL="Select * from VTDi where Phanloai="& bPhanloai &" and year(ngaydi)='"& bNam &"' order by so"
				'sSQL="Select * from VTDi where year(ngaydi)='"& bNam &"'  order by so"
				Set RecTD=server.createobject("ADODB.Recordset")
				RecTD.cursorType=3
				RecTD.Cachesize=5
				RecTD.open sSQL,Conn
				if (not RecTD.EOF) and (not RecTD.BOF) then
					RecTD.MOvelast
					bOutnum=cstr(clng(RecTD("so"))+1)
				else
					bOutnum="1"
				end if
			end if
			RecTD.close
			Set RecTD=nothing
			bSoghinhan=trim(bOutnum) & "/" & trim(bOutSymbol)
			Temp=bSoghinhan
			bID="DI"+cstr(year(bNgayky))+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)
			bTentep=bID+".VT"
			bNguoiduyet=Session("bMaCB")
			bNgayky=SaveDate(bNgayky)
			bNgaydi=SaveDate(bNgaydi)
			Msg="N&#7897;i dung c&#7853;p nh&#7853;t"
			bTonTai=false
			bComm="edit"				
			bNamCu=bnam
			bPhanloaicu=bPhanloai
			bNhomCVcu=bNhomCV
			bOutnumcu=bOutnum
			if not bTonTai then				
				'Tao Transaction
				On Error resume next
				Conn.BeginTrans			
				'Loc so tu dong theo nam + Phan loai					
				sSQL="Insert Into VTDi(ID,so,soghinhan,tomtat,trichyeu,tinhchat,tinhchat1,soto,soban,phanloai,tentep,nguoiky,ngaydi,ngayky,diachiluutru,nguoinhan,tukhoa,congcong, trangthaiduyet,nguoiduyet,loai,soluongnoidung,noinhan,DVSoan,baocao) values('"& modistring(bID) &"',"& bOutnum &",'"& modistring(bSoghinhan) _
						&"','"& ModiString(trim(bTomtat)) &"','"& ModiString(bTrichyeu) &"','"& ModiString(bTinhchat) &"','"& ModiString(bTinhchat1) _
						&"','"& ModiString(bSoto) &"','"& ModiString(bSoban) &"',"& bPhanloai _
						&",'"& ModiString(bTentep) &"','"& ModiString(bNguoiky) _
						&"','"& bNgaydi &"','"& bNgayky &"',"& bDiachiluutru  _						
						&",'"& ModiString(bNguoinhan) _
						&"','"& ModiString(bTukhoa) &"',"& ModiString(bReadwrite) _
						&","& bTTDuyet &",'"& bNguoiduyet &"','2','"& bSLNoidung &"','"& bSelect2 &"','"& bSelect1 &"','"& bBaocao &"')"					
				Conn.Execute sSQL
				%><%=Err.Description%><%
				bSoghinhancu=bSoghinhan
				bIDcu=bID
				
				'******************
				if bDangky="ok" then
					set Obj=server.CreateObject("ActiveFile.File")
					IDFlow=Request("IDFLow")
					sSQL="Select Tentepxuly from workflow where maworkflow like '"& IDFlow &"'"
					Set RecTT=server.CreateObject("ADODB.Recordset")
					RecTT.CursorType=3
					RecTT.CacheSize=5
					RecTT.Open sSQL,Conn
					if RecTT.RecordCount then
						tentep=RecTT("Tentepxuly")
					end if
					RecTT.Close
					Set RecTT=nothing
					Path1=RootContent & "Data\yeucau\TEXT"  & "\"& IDFlow & ".VT"
					obj.Name=Path1
					fname=bID & ".VT"
										
					'Tao thu muc nam moi
				Set bDir=server.CreateObject("ActiveFile.Directory")
		     	bPathFolder=RootContent & "Upload"& "\" & bNam
		     	
		          bDir.Path=bPathFolder
    				if not bDir.Exists() then
    				   	call bDir.Create(bPathFolder)
    				end if    				
	    			bPathFolder=bPathFolder & "\Di"
				bDir.Path=bPathFolder
	     		if not bDir.Exists() then
					Call bDir.Create(bPathFolder)
				end if
				
				bPathFolder=bPathFolder & "\Text"
			    	bDir.Path=bPathFolder
				if not bDir.Exists() then
	   				Call bDir.Create(bPathFolder)
				end if
			     Set bDir=nothing		          							
'				TextFile.Name=Path


					if obj.Exists() then
						obj.Name=RootContent & "upload\"& bNam &"\DI\TEXT\"& fname
						if obj.Exists() then
							obj.Delete()
						end if
						Obj.Name=Path1						
						Path2=RootContent & "upload\"& bNam &"\DI\TEXT\"& fname					
						Obj.Copy(Path2)
						bTentep=fname
					else
						loi=true
					end if					
					
					Set TextFile=server.CreateObject("Vinalines.ClsFile")
					bTEXT=TextFile.ReadTextFile(path1)
					sSQL="Select Tentep,mota from workflow_tentep where maworkflow like '"& IDFlow &"'"					
					Set RecWF=server.CreateObject("ADODB.Recordset")
					RecWF.CursorType=3
					RecWF.CacheSize=5
					RecWF.Open sSQL,Conn	
					
					if RecWF.RecordCount then
						STT=0
						Do while not RecWF.EOF
							STT=STT+1
							Tentep=bID & "S" & cstr(STT) & "."  & TextFile.GetExtensionFile(RecWF("Tentep"))
							P1=RootContent & "\Data\yeucau" & "\" & RecWF("Tentep")
							Obj.Name=P1						
							if Obj.Exists() then
								P2=RootContent & "upload\"& bNam &"\DI\"& Tentep
								Obj.Copy(P2)
							end if
							sSQL="Insert into vanban_Noidung(Mavanthu,Loaivanthu,SoThutu,tentep,mota) values('"& bID &"','2',"& cstr(STT) &",'"& tentep &"','"& RecWF("mota") &"')"
							Conn.Execute sSQL							
							RecWF.MoveNext
						Loop
					end if
					
					RecWF.Close
					Set RecWF=nothing
					Set TextFile=nothing
					set Obj=nothing
					'Chuyen doi trang thai Workflow
					bMaflowgiaima=giaima(request("maflow")	)
					 sSQL = "Update Flownode Set trangthaixl=2 where Maworkflownode like '" & bMaFlowgiaima & "'"
					Conn.Execute sSQL
					bLen = ItemLast(bMaFlowgiaima) * 2 - 1
					bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
					For i = ItemLast(bItem) + 2 To (Len(bMaFlowgiaima) - 1) / 2
						bItem = bItem & "00"
					Next
					sSQL = "Update Flownode Set trangthaixl=0 where  trangthaixl=-1 and Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
					Conn.Execute sSQL	                  
					Call Xuly(bItem,bMaFlowgiaima,true)
					sSQL="Update flownode set thuhoi=1 where maworkflow='"& left(bMaflowgiaima,5) &"'"
					Conn.Execute sSQL
					%><%=Err.Description%><%
				end if
		'*****************
				'Ket Thuc Transaction								

				if Err.number=0 then
					if Session("VanBan")="" then 
						Session("VanBan")="-" & Session("VanBan") & modistring(bID) & "-"
					else
						Session("VanBan")=Session("VanBan") & modistring(bID) & "-"
					end if
					Session("sSQLDi")=""
					Conn.CommitTrans
					bTrangthai=1
				else
					Conn.RollbackTrans
					bTrangthai=0
				end if
				'Ghi nhan Ai da login thanh cong				
				bHoten=Session("bHoten")
				bNgaygio=cstr(Date()) &" "& cstr(Time())
				bChucnang="C&#7853;p nh&#7853;t V&#259;n th&#432; quyết định"
				bIDTailieu=bSoghinhan
				bDongtac="Th&#234;m m&#7899;i"
				sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
					&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"','"& bTrangthai &"')"
				Conn.Execute sSQL	
				
				Session("bMaVBQD")=bID
				Session("bTenVBQD")=bTrichyeu
			end if
	end select
	if bComm=""  then
		bVuviec=false
	else
		bVuviec=true
	end if
	'Kiem tra(Lay quyen va ma van thu) quyen doi voi van thu
	if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin") then
		bQuyen="F"
	else
		sSQL="Select * from Quyen Where Mavanthu like '"& bID &"' and Macanbo like '"& Session("bMaCB") &"' and maloaivanthu like '2'"
		Set RecKTQ=server.CreateObject("ADODB.Recordset")
		RecKTQ.CursorType=3
		RecKTQ.CacheSize=5
		RecKTQ.Open sSQL,Conn
		if RecKTQ.RecordCount>0 then
			bQuyen=RecKTQ("Quyen")
		end if
		RecKTQ.Close
		set RecKTQ=nothing		
	end if%>	
<%if Msg<>"" then%>
	<p align=center><font face=Arial color=red><%=Msg%></font></p>
<%end if%>	
<!--#include file="..\jvfunction.inc"-->
<script language=vbscript runat=server>
'******Giai ma xau************************
	Function GiaiMa(msText) 
	    Dim nC
	    Dim nD
	    Dim nE
	    Dim lA
	    Dim lB
	    Dim lI
	    Dim lJ
	    Dim lK
	    Dim sB
	    lA = Len(msText)
	    lB = lA - 1 - (lA - 1) \ 4
	    sB = Space(lB)
	    For lI = 1 To lB
	        lJ = lJ + 1
	        nC = Asc(Mid(msText, lJ, 1)) - 59	        
	        Select Case lI Mod 3
	        Case 1
	            lK = lK + 4
	            If lK > lA Then lK = lA
	            nE = Asc(Mid(msText, lK, 1)) - 59
	            nD = ((nE \ 16) And 3) * 64
	        Case 2
	            nD = ((nE \ 4) And 3) * 64
	        Case 0
	            nD = (nE And 3) * 64
	            lJ = lJ + 1
	        End Select
	        sB=Mid(sB,1,lI-1) & Chr(nC Or nD) & Mid(sB,lI+1,len(sB)-lI)
	    Next
	    GiaiMa = sB
	End Function
	Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
	End Function
'Chuyen doi ma
Function DoiMa(st)
    Dim i
    st = Trim(st)
    If Len(st) = 0 Then
        DoiMa = ""
    Else
        For i = 1 To Len(st)
            Select Case Mid(st, i, 1)
                Case "-"
                    st=Replace(st,"-","_")
                Case "+"
                    st=Replace(st,"+","_")
                Case "*"
                    st=Replace(st,"*","_")
                Case "\"            
                    st=Replace(st,"\","_")
                Case "/"
                    st=Replace(st,"/","_")
                Case "?"
                    st=Replace(st,"?","_")
                Case "!"
                    st=Replace(st,"!","_")
                Case ","
                    st=Replace(st,",","_")
                Case ":"
                    st=Replace(st,":","_")
                Case ";"
                    st=Replace(st,";","_")
                Case "^"
                    st=Replace(st,"^","_")
                Case "|"
                    st=Replace(st,"|","_")
                Case " "
                    st=Replace(st," ","_")
                Case "("
                    st=Replace(st,"(","_")
                Case ")"
                    st=Replace(st,")","_")
                Case "["
                    st=Replace(st,"[","_")
                Case "]"
                    st=Replace(st,"]","_")
                Case "{"
                    st=Replace(st,"{","_")
                Case "}"
                    st=Replace(st,"}","_")
                Case "<"
                    st=Replace(st,"<","_")
                Case ">"
                    st=Replace(st,">","_")
                Case "."
                    st=Replace(st,".","_")
            End Select
        Next
        DoiMa = st
    End If
End Function
'Dung de kich hoat dong con khi cha no duoc kich hoat hoacmo di
Function Xulycon(bMa,bActive)
	if bActive then 'Khi nut cha duoc phep xu ly
		sSQL="Select * from flownode where maworkflow like '"& bMa &"' order by maworkflownode"
		Set RecXLC=server.CreateObject("ADODB.Recordset")
		RecXLC.CursorType=3
		RecXLC.CacheSize=5
		RecXLC.Open sSQL,Conn
		Do While not RecXLC.EOF
			bCond=Itemlast(RecXLC("maworkflownode"))
			if bCond=2 then
				sSQL="Update flownode set trangthaixl=0 where trangthaixl=-1 and maworkflownode like '"& RecXLC("maworkflownode") &"'"
				Conn.Execute sSQL
			end if
			RecXLC.MoveNext
		Loop
		RecXLC.Close
		set RecXLC=nothing
	else 'Khi nut cha khong duoc phep xu ly
		sSQL="Update flownode set trangthaixl=-1 where maworkflow like '"& bMa &"'"
		Conn.Execute sSQL
	end if	
End Function
'Xuly cac nut con sau khi nut con cua mot nhanh khac xu ly
Function Xuly(bMaflownode,bCurrent,bActive)
	sSQL="Select * from flownode where maworkflownode like '"& bMaflownode &"' and Maworkflownode<>'" & bCurrent & "'"
	Set RecTimcon=server.CreateObject("ADODB.Recordset")
	RecTimcon.CursorType=3
	RecTimcon.CacheSize=5
	RecTimcon.Open sSQL,Conn
	Do while not RecTimcon.EOF
		if not isnull(RecTimcon("maworkflowcon")) then	
			Call Xulycon(RecTimcon("maworkflowcon"),bActive)
			RecTimcon.MoveNext
		end if
		RecTimcon.MoveNext
	Loop
	RecTimcon.Close
	Set RecTimcon=nothing
End Function
	' H&#224;m &#273;&#7883;nh d&#7841;ng l&#7841;i ng&#224;y M/D/Y-> D/M/Y		
	Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
	End Function
	Function ModiString(mess_s)
		message = Replace("" & mess_s,"'", "''")
		ModiString=message
	End function
	'Kiem tra so ghi nhan
	Function KTSoghinhan(bValueO,bLoaiVB,bValueY,loai)
		KTSoghinhan=false
		if loai="okedit" then			
				sSQL="Select * from VtDi where phanloai="& bLoaiVB &" and so= "& bValueO &" and year(ngaydi)="& bValueY
				set RecKT=server.CreateObject("ADODB.Recordset")
				RecKT.CursorType=3
				RecKT.CacheSize=5
				RecKT.Open sSQL,Conn
				if (not RecKT.BOF) and (not RecKT.EOF) then
					KTSoghinhan=true
				end if
				RecKT.Close
				set RecKT=nothing				
		end if
		if loai="okadd" then
			sSQL="Select ID from vtDi where phanloai="& bLoaiVB &" and so= "& bValueO &" and year(ngaydi)="& bValueY
			set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			RecKT.Open sSQL,Conn
			if (not RecKT.BOF) and (not RecKT.EOF) then
				KTSoghinhan=true
			end if
			RecKT.Close
			set RecKT=nothing				
		end if			
	end function
	    'Vi tri bit so sanh
Function ItemLast(Item)
        Dim i
        Dim It
        Dim vt
        Dim j, Temp
        It = Item
        It = Right(It, Len(It) - 4)
        j = 1
        For i = 2 To Len(It)
            If i < Len(It) Then
                Temp = Mid(It, i, 1)
                i = i + 1
                Temp = Temp & Mid(It, i, 1)
                j = j + 1
                If Temp = "00" Then
                    ItemLast = j - 1
                    Exit For
                Else
                    If i = Len(It) Then
                        ItemLast = j
                    End If
                End If
            End If
        Next
    End Function
</script>	
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function CmdDuyet_onclick() {
	<%if bComm="add" then %>
		alert("Bạn phải ghi nhận công văn trước");
		return false;
	<%end if%>
	if (!Noidung.CheckReadwrite.Checked){
	<%if bReadwrite then %>
		alert("Bạn phải ghi nhận công văn trước");
		return false;
	<%end if%>
	}
	mavt=window.Noidung.TxtID.value;
	window.Noidung.target="right";
	bduyet="duyetcanbo.asp?bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bstepduyet=0&bCommDuyetCB="+'<%=bComm%>'+"&MaVT="+mavt+"&bMaLoaiVT=2";
	window.Noidung.action=bduyet
	window.Noidung.submit();
}

function CmdAdd_onclick() {
	<%if bDangky="ok" then%>
		window.Noidung.action="frmvtDi.asp?FilenameChuyen="+"<%=request("Filenamechuyen")%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=add";
	<%else%>
		window.Noidung.action="frmvtDi.asp?bComm=add";
	<%end if%>	
	window.Noidung.target="right";
	window.Noidung.submit();
}
function KTNhap(){
	if(trim(Noidung.TxtOutSymbol.value)==""){
		alert("Bạn cần phải nhập ký hiệu");
		Noidung.TxtOutSymbol.focus();
		return false;
	}
	if (trim(Noidung.TxtTrichyeu.value)==""){
		alert("Bạn cần phải nhập trích yếu");
		Noidung.TxtTrichyeu.focus();
		return false;
	}
	if (trim(Noidung.TxtNgayky.value)==""){
		alert("Bạn cần phải nhập ngày ký");
		Noidung.TxtNgayky.focus();
		return false;
	}	
	if (!isDate(Noidung.TxtNgayky.value)){
		alert("Ngày ký không hợp lệ");
		Noidung.TxtNgayky.focus();
		return false;
	}
	if (trim(Noidung.TxtNguoiky.value)==""){
		alert("Bạn cần phải nhập người ký");
		Noidung.TxtNguoiky.focus();
		return false;
	}
	if (trim(Noidung.ComboTinhchat.value)==""){
		alert("Bạn cần phải nhập tính chất");
		Noidung.ComboTinhchat.focus();
		return false;
	}
	return true;
}

function CmdOK_onclick() {	
	if (KTNhap()){
		if(trim(Noidung.TxtNgayky.value)!=""){	
			if (!isDate(Noidung.TxtNgayky.value)){
				alert("Ngày ký không hợp lệ");
				Noidung.TxtNgayky.focus();
				return false;
			}
		}
		<% if Request("ChuyenVTDi")="ok" then%>
		Noidung.ComboPhanloai.value=Noidung.PL.value;
		<%end if%>
		Noidung.TxtOutNum.disabled=false;
		Noidung.TxtOutSymbol.disabled=false;
		<%if bComm="edit" then%>
			window.Noidung.target="right"
			window.Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+ "<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet="+ "<%=bTTDuyet%>"
		window.Noidung.submit()
		<%end if%>
		<%if bComm="add" then%>			
			window.Noidung.target="right"
			window.Noidung.action="frmvtDi.asp?bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+ "&IDFlow="+"<%=request("IDFLow")%>"+"&bComm=okadd"+"&bReadwrite=" +Noidung.CheckReadwrite.checked+"&bTTDuyet=false&maflow="+"<%=maflow%>";
			window.Noidung.submit()
		<%end if%>
	}
}
function CmdOKDuyet_onclick(){
		Noidung.TxtOutNum.disabled=false;
		<%if bComm="add" then %>
			alert("Bạn cần phải ghi nhận công văn trước");
			return false;
		<%end if%>
		if (KTNhap()){
		if(Noidung.TxtNgayky.value!=""){	
			if (!isDate(Noidung.TxtNgayky.value)){
				alert("Ngày ký không hợp lệ");
				Noidung.TxtNgayky.focus();
				return false;
			}
		}
		Noidung.TxtOutSymbol.disabled=false;
		<%if bComm="edit" then%>
			window.Noidung.target="right"
window.Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet=True"

		window.Noidung.submit()
		<%end if%>
	}
}
function CmdNotOKDuyet_onclick(){
	
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>
		if (KTNhap()){
		if(trim(Noidung.TxtNgayky.value)!=""){	
			if (!isDate(Noidung.TxtNgayky.value)){
				alert("Ngày ký không hợp lệ");				
				Noidung.TxtNgayky.focus();
				return false;
			}
		}
		Noidung.TxtOutSymbol.disabled=false;
		Noidung.TxtOutNum.disabled=false;
		<%if bComm="edit" then%>
			Noidung.target="right"
			Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet=false"
		Noidung.submit()
		<%end if%>
	}
}
function CmdExit_onclick() {	
	<%if Request("bDangky")="ok" then%>
		window.history.go(-<%=Backform%>);
	<%else%>
		Noidung.target="right"
		//Noidung.action="frmdsvtDi.asp?bComm=search&bBack=ok";
		Noidung.action="frmdsvtDi.asp?bComm=";
		Noidung.submit();
	<%end if%>
}

function CmdCancel_onclick() {
	Noidung.CmdOK.disabled=true;
	Noidung.CmdCancel.disabled=true;
}
function CmdXacnhan_onclick() {
	if(Noidung.TxtPsw.value=="<%=Giaima(Session("Pass"))%>"){
		if(Noidung.CheckDuyet.disabled){
			Noidung.CheckDuyet.disabled=false;
			Noidung.CmdNoidungtep.disabled=false;
		}
		else{
			Noidung.CheckDuyet.disabled=true;
			Noidung.CmdNoidungtep.disabled=true;
		}
		return true
	}
	else{
		alert("B&#7841;n x&#225;c nh&#7853;n sai m&#7853;t kh&#7849;u !")
		return false;
	}
	Noidung.TxtPsw.value="";
}
function CheckReadwrite_onclick(){
	if (Noidung.CheckReadwrite.checked){
		Noidung.CmdDuyet.disabled=true;
		CmdOK_onclick();
	}		
	else{
		Noidung.CmdDuyet.disabled=false;
		CmdOK_onclick();
	}
}

function CmdXemNoidung_onclick(){	
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>	
	if (Noidung.TxtID.value!=""){
		window.Noidung.target="_blank";
		bMa=Noidung.TxtID.value;
		window.Noidung.action="xemnoidung.asp?LoaiVt=2&bMa="+bMa+"&bNam="+"<%=bNam%>"
		window.Noidung.submit();
	}
}
function CmdNoidungtep_onclick() {	
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>	
	<%if bQuyen="" or bQuyen="R" then%>
		alert("B&#7841;n kh&#244;ng c&#243; quy&#7873;n s&#7917;a &#273;&#7893;i n&#7897;i dung v&#259;n th&#432;");
		return false;
	<%end if%>
	<% if bComm="edit" then%>
		bMa=Noidung.TxtID.value;
		a="../editor/frmedit.asp?bMa="+bMa+"&bLoaiVT=2&bNam="+"<%=bNam%>"+"&bNamcu="+"<%=bNamCu%>";
		window.Noidung.action=a;
		window.Noidung.target="right";
		window.Noidung.submit();
	<%end if%>		
}
function cmddangkyvv_onclick() {
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>
	<%if bVuviec then%>
		window.Noidung.target="main";
		window.Noidung.action="dangkyvuviec/frmdangky.asp?LoaiVt=2";
		window.Noidung.submit();
	<%else%>
		alert("B&#7841;n c&#7847;n ph&#7843;i ch&#7885;n v&#259;n th&#432; &#273;&#7875; &#273;&#259;ng k&#253;");
	<%end if%>
}
function CmdThemVV_onclick() {
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");		
		return false;
	<%end if%>
	<%if bVuviec then%>
		window.Noidung.target="right"
		window.Noidung.action="frmvuviec.asp?bcallfrmvtden=ok&bTrichyeuvtden="+Noidung.TxtTrichyeu.value;
		window.Noidung.submit();
	<%else%>
		alert("B&#7841;n c&#7847;n ph&#7843;i ch&#7885;n m&#7897;t v&#259;n th&#432; l&#224;m vi&#7879;c");
	<%end if%>
}

function CmdNext_onclick() {
	if(Noidung.TxtTTNoidung.value<Noidung.TxtSLNoidung.value){
		Noidung.TxtTTNoidung.value=++Noidung.TxtTTNoidung.value;		
	}
}

function CmdPrv_onclick() {
	if(Noidung.TxtTTNoidung.value>1){
		Noidung.TxtTTNoidung.value=--Noidung.TxtTTNoidung.value;
	}
}
function CmdNext1_onclick() {
	if(Noidung.TxtSLNoidung.value<3){
		Noidung.TxtSLNoidung.value=++Noidung.TxtSLNoidung.value;		
	}
}
function CmdPrv1_onclick() {
	if(Noidung.TxtSLNoidung.value>1){
		Noidung.TxtSLNoidung.value=--Noidung.TxtSLNoidung.value;
		if(Noidung.TxtTTNoidung.value>Noidung.TxtSLNoidung.value){
			Noidung.TxtTTNoidung.value=Noidung.TxtSLNoidung.value;
		}
	}
}
function ComboNguoiky_onchange() {
	Noidung.TxtNguoiky.value=Noidung.ComboNguoiky.value;
}
function ComboNguoinhan_onchange() {
	Noidung.TxtNguoinhan.value=Noidung.ComboNguoinhan.value;
}
function ComboOutSymbol_onchange() {
	Noidung.TxtOutSymbol.value=Noidung.ComboOutSymbol.value;
}
function openNN(sObj) {
  popupWin = window.open('Search.asp?bType=DI','new_page','width=300,height=300').focus();
}
function openDV(sObj) {
  popupWin = window.open('AddDV.asp?bType=DI','new_page','width=300,height=300').focus();
}
function CmdEmail_onclick() {
	Noidung.target="_blank";
	bMa=Noidung.TxtID.value;
	Noidung.action="compose.asp?bLoaiVt=2&bMa="+bMa+"&bNam="+"<%=bNam%>";
	Noidung.submit();
}

function TxtNgayky_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	Noidung.TxtNgayky.value=editdate(trim(str))
}
}

function TxtNgaydi_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	Noidung.TxtNgaydi.value=editdate(trim(str))
}
}

//-->
</SCRIPT>
<body bgcolor="#F8F9D9" topmargin="0" leftmargin="0" style="font-family:Times New Roman">
<Form name="Noidung" Method="Post" >
<input type=hidden name=chuyendi value="<%=trim(chuyendi)%>">
<input type=hidden name=ComboPhanloai value="<%=bPhanloai%>">
<%if bDisplay then
	txt="<td width='200' align='left'><input type=hidden name='TxtID' size='50' value='"& bID &"' style='font-family:Arial'></td>"
	Response.Write(txt)
else
	if bComm<>"add" then
		txt="<td width='200' align='left'><input type=hidden name='TxtID' value='"& bID &"' size='50' style='font-family:Arial'></td>"
		Response.Write(txt)
	else
		txt="<td width='200' align='left'><input type=hidden name='TxtID' value='"& AutoSoghinhan &"'size='50' style='font-family:Arial'></td>"
		Response.Write(txt)
	end if
end if%>
<!-- Form nhap lieu -->
<table width="100%" border="0" cellspacing="0" style="font-size:12pt;BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bgcolor="#BDD5D0">
  <tr>
    <td width="100%" colspan="5" bgcolor="#000080" align=center><font color="#FFFFFF"><span style="font-size: 11pt">CÔNG VĂN ĐI</span></font></td>
  </tr>
  <tr>
    <td width="15%">Ngày đi</td>
	<td width="85%" colspan="4">
    <%if bDisplay then%>
			<input name=TxtNgaydi value="<%= formatdate(bNgaydi) %>" maxLength=10 size=10  style='font-family:Arial' LANGUAGE=javascript onkeyup="return TxtNgaydi_onkeyup(this.value)">    
			Số, Ký hiệu
			<input name='TxtOutNum' value='<%= bOutNum %>' size=10  maxLength=20 style='font-family:Arial'>/
			<input name=TxtOutSymbol size=20 value='<%=bOutSymbol %>' style="font-family:'Times new roman'">			
	<%else
		if bComm<>"add" then%>
				<input name=TxtNgaydi value="<%= formatdate(bNgaydi) %>" maxLength=10 size=10  style='font-family:Arial' LANGUAGE=javascript onkeyup="return TxtNgaydi_onkeyup(this.value)">
				Số, Ký hiệu
				<input name='TxtOutNum' value='<%= bOutNum %>' size=10  maxLength=20 style='font-family:Arial'>/
				<input name=TxtOutSymbol size=20 value='<%=bOutSymbol %>' style="font-family:'Times new roman'">	
		<%else%>
				<input name=TxtNgaydi value="<%= formatdate(date()) %>" maxLength=10 size=10 style='font-family:Arial' LANGUAGE=javascript onkeyup="return TxtNgaydi_onkeyup(this.value)">
				Số, Ký hiệu
				<%	
				Set RecMax=Server.createObject("ADODB.Recordset")
				RecMax.CursorType=3
				RecMax.CacheSize=5
				sSQL="Select * from VTDi where Phanloai="& bPhanloai &" and year(ngaydi)=year(getdate()) order by so"
				RecMax.Open sSQL,Conn
				if RecMax.recordcount then
					RecMax.movelast
					AutoSoghinhan =cstr(cint(RecMax("so"))+1)
				else
					AutoSoghinhan ="1"
				end if
				RecMax.close
				set RecMax=nothing
				
				Set RecMax=Server.createObject("ADODB.Recordset")
				RecMax.CursorType=3
				RecMax.CacheSize=5
				sSQL="Select * from phan_loai_di where IDLoai="& bPhanloai 
				RecMax.Open sSQL,Conn
				if RecMax.recordcount then
					bTenHT=RecMax("Ma_ky_hieu")
				end if
				RecMax.close
				set RecMax=nothing
				
				%>
				<input name='TxtOutNum' value="<%=AutoSoghinhan%>" size=10 maxLength=10 style='font-family:Arial'>/
				<input name=TxtOutSymbol value="<%=trim(bTenHT)%>" size=20 style="font-family:Times new roman">
		<%end if		
	end if%>	   
		</td>  
  </tr>
  <tr>
    <td width="15%" >Trích yếu</td>
	<td width="85%" colspan="4">
    <%if bDisplay then%>
		<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=1 cols="82"><%= bTrichyeu %></textarea></td>
	<%else
		if bComm<>"add" then%>
			<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=1 cols="82"><%= bTrichyeu %></textarea></td>
		<%else
			if Request("ChuyenVTDi")="ok" then
				Set RecTY=server.CreateObject("ADODB.Recordset")
				RecTY.CursorType=3
				RecTY.CacheSize=5
				sSQL="Select Tenvuviec from workflow where Maworkflow like '"& Request("IDFlow") &"'"
				RecTY.Open sSQL,Conn
				if RecTY.RecordCount then
					if trim(RecTY("Tenvuviec"))<>"" then%>
						<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' cols=82 rows=1><%= RecTY("Tenvuviec")%></textarea></td>
					<%else%> 
						<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' cols=82 rows=1></textarea></td>
					<%end if%>
				<%else%>
					<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=1 cols=82></textarea></td>
				<%end if
				RecTY.Close
				set RecTY=nothing
			else%>
				<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=1 cols=82> <%=request("bSubject") %></textarea></td>
			<%end if
		end if
	end if%>
  </tr>
  <tr>
    <td width="15%" >Tóm tắt ND</td>
	<td width="85%" colspan="4">
    <%if bDisplay then%>
		<Textarea name=TxtTomtat maxlength=500  style='font-family:Arial; width:100%' rows="2" cols="20"><%=trim(bTomtat)%></textarea></td>
	<%else
		if bComm<>"add" then%>
            <Textarea name=TxtTomtat maxlength=500  style='font-family:Arial; width:100%' rows="2"><%=trim(bTomtat)%></textarea></td>
		<%else%>
            <Textarea name=TxtTomtat maxlength=500 style='font-family:Arial; width:100%' rows="2"></textarea></td>
		<%end if
	end if%>
  </tr>
  <tr>
    <td width="15%" >Ngày ký</td>
    <%if bDisplay then%>
		<td width="20%" ><input type="text" name=TxtNgayky value='<%= formatdate(bNgayky) %>' size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)"></td>
	<%else
		if bComm<>"add" then%>
			<td width="20%" ><input type="text" name=TxtNgayky value='<%= formatdate(bNgayky) %>' size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)"></td>
		<%else%>
			<td width="20%" ><input type="text" name=TxtNgayky value="<%= FormatDate(Date) %>" size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)"></td>
		<%end if
	end if%>    
    <td width="15%" align="center">Người ký</td>
	<td width="25%" align=center>
    <%if bDisplay then%>
			<input type="text" name=TxtNguoiky size=25 value='<%= bNguoiky %>' maxLength=60 style='font-family:Arial;width:100%'></td>
		<%else
			if bComm<>"add" then%>
				<input type="text" name=TxtNguoiky size=25 value='<%= bNguoiky %>' maxLength=60 style='font-family:Arial;width:100%'></td>
			<%else%>
				<input type="text" name=TxtNguoiky size=25 maxLength=60 style='font-family:Arial;width:100%'></td>
			<%end if
	  end if
	'	sSQL="Select * from doitac_nguoi order by ten"
		sSQL="Select hovaten from canbo order by hovaten"
		Set RecCB=server.CreateObject("ADODB.Recordset")
		RecCB.CursorType=3
		RecCB.CacheSize=5
		RecCB.Open sSQL,Conn%>
		<td width="25%"><select size=1 name=ComboNguoiky style='font-family: Arial;width:100%' LANGUAGE=javascript onchange='return ComboNguoiky_onchange()'>
			<option value='' selected>
			<%Do While not RecCB.EOF%>
			<option value='<%=RecCB("Hovaten")%>'><%=RecCB("Hovaten")%>
			<%RecCB.MoveNext
			Loop
			txt="</select>"
			Response.Write(txt)
			RecCB.Close
			Set RecCB=nothing
		%>        
	</td>
  </tr>
 <tr>
    <td width="15%" >Khẩn/mật</td>
    <td width="35%" colspan=2>
    <select size="1" name="ComboTinhchat" style="font-family: Arial; height: 23; position: relative; width:100%">
		<%
			sSQL="Select * from Tinhchat"
			Set RecTC=Server.CreateObject("ADODB.Recordset")
			RecTC.CursorType=3
			RecTC.CacheSize=5
			RecTC.Open sSQL,Conn
			Do While not RecTC.EOF
				if bDisplay then
					if RecTC("ma")=bTinhchat then		
		%>				<option Selected value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
		<%			else%>
						<option value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
		<%			end if
				else%>
					<%if bComm<>"add" then
						if RecTC("ma")=bTinhchat then		
		%>					<option Selected value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
		<%				else%>
							<option value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
		<%				end if
					else%>
						<option value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
					<%end if%>
		<%		end if
				RecTC.MoveNext
			Loop
			RecTC.Close
			set RecTC=nothing
		%>
		</select>
	</td>
    <td width="50%" colspan=2>
	 <%if bDisplay then%>
		 	Số bản <input type="text" name=TxtSoban value="<%=bSoban%>" style="font-family:times new roman" size=2 maxlength=4>
		 	Số tờ <input type="text" name=TxtSoto value="<%=bSoto%>" style="font-family:times new roman" size=2 maxlength=4>
	<%else
		if bComm<>"add" then%>
			Số bản <input type="text" name=TxtSoban value="<%=bSoban%>" style="font-family:times new roman" size=2 maxlength=4>
		 	Số tờ <input type="text" name=TxtSoto value="<%=bSoto%>" style="font-family:times new roman" size=2 maxlength=4>
		<%else%>
			Số bản <input type="text" name=TxtSoban style="font-family:times new roman" size=2 maxlength=4>
		 	Số tờ <input type="text" name=TxtSoto style="font-family:times new roman" size=2 maxlength=4>
		<%end if
	end if%>    		
		<%if bBaocao or bComm="add" then%>
				<label for=C1 accesskey="V">Điểm <u>v</u>ăn bản</label><input name=ChkBC type=checkbox  checked value="ON" id=C1>
		<%else%>
				<label for=C1 accesskey="V">Điểm <u>v</u>ăn bản</label><input name=ChkBC type=checkbox value="ON" id=C1>
		<%end if%>
    </td>
  </tr>
<% if Request("ChuyenVTDi")="ok" then%>
	<tr>
    <td width="15%" >Loại VB</td>
    <td width="85%" colspan=4>
    		<%
        sSQL="Select * from Phan_loai_di"
		Set RecCB=server.CreateObject("ADODB.Recordset")
		RecCB.CursorType=3
		RecCB.CacheSize=5
		RecCB.Open sSQL,Conn%>
		<select size=1 name=PL style='font-family: Arial;width:100%'>
		<%Do While not RecCB.EOF	%>
				<option value=<%=RecCB("IDLoai")%>><%=RecCB("Ten_hinh_thuc")%>
				<%RecCB.MoveNext
		Loop
		txt="</select>"
		Response.Write(txt)
		RecCB.Close
		Set RecCB=nothing%>         
      </td>
  </tr>
<%end if%>
  <tr>
	<td width="15%"><input type=button onclick="javascript:openDV()" value="Đơn vị soạn" name=CmdDonvi style="font-family:Arial;width:100%; background-color=#BDD5D0"></td>
	<td width="85%" colspan="4">
    <input type="text" name="select1"  maxlength=500 value="<%=bselect1%>" style="font-family:Arial;width:100%" size="20"></td>
  </tr>
  <tr>
	<td width="15%"><input type=button onclick="javascript:openNN()" value="Nơi nhận" name=CmdNoinhan style="font-family:Arial;width:100%; background-color=#BDD5D0"></td>
	<td width="85%" colspan="4">
    <input type="text" name=select2 maxlength=500 value="<%=bselect2%>" style="font-family:Arial;width:100%" size="20"></td>
  </tr>
<!-- DIA CHI LUU TRU
  <tr>
    <td width="15%" align=left>Đ/c lưu trữ</td>
    <td width="85%" colspan="4">
      <%
   		sSQL="Select * from Diachiluutru"
		Set RecCB=server.CreateObject("ADODB.Recordset")
		RecCB.CursorType=3
		RecCB.CacheSize=5
		RecCB.Open sSQL,Conn
		Txt="<select size=1 name=TxtDiachiluutru style='font-family: Arial; height: 23;width:100%; position: relative'>"
		Response.Write(txt)%>				
		<%Do While not RecCB.EOF				
				if bDisplay then
					if trim(cstr(RecCB("IDLuutru")))=trim(bDiachiluutru) then		
		%>				<option Selected value=<%=RecCB("IDLuutru")%>><%=RecCB("Ten")%>
		<%			else%>
						<option value=<%=RecCB("IDLuutru")%>><%=RecCB("Ten")%>
		<%			end if
				else%>
					<%if bComm<>"add" then
						if trim(cstr(RecCB("IDLuutru")))=trim(bDiachiluutru) then		
		%>					<option Selected value=<%=RecCB("IDLuutru")%>><%=RecCB("Ten")%>
		<%				else%>
							<option value=<%=RecCB("IDLuutru")%>><%=RecCB("Ten")%>
		<%				end if
					else%>
						<option value=<%=RecCB("IDLuutru")%>><%=RecCB("Ten")%>
					<%end if%>
		<%		end if
				RecCB.MoveNext
		Loop
		txt="</select>"
		Response.Write(txt)
		RecCB.Close
		Set RecCB=nothing%>
	</td>		
  </tr>
-->
  <tr>
    <td width="15%" >Từ khóa</td>
    <%if bDisplay then%>
		<td width="60%" colspan="3" ><input type="text" name=TxtTukhoa size=55 value='<%= bTukhoa %>' maxLength=100 style='font-family:Arial'></td>
		<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),5)="1" or Session("IsAdmin") then %>
		<td width="25%" align=right>
			<Button name="CmdEmail" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
			<Button name="CmdOK" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
		<%else%>
		<td width="25%" align=right>
			<Button disabled name="CmdEmail" style="font-family: Arial;width:70" LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
			<Button name="CmdOK" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
		<%end if%>
	<%else
		if bComm<>"add" then%>
			<td width="60%" colspan="3" ><input type="text" name=TxtTukhoa size=55 value='<%= bTukhoa %>' maxLength=100 style='font-family:Arial'></td>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),5)="1" or Session("IsAdmin") then %>
			<td width="25%" align=right>
				<Button name="CmdEmail" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
				<Button name="CmdOK" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
			<%else%>
			<td width="25%" align=right>
				<Button disabled name="CmdEmail" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
				<Button name="CmdOK" style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
			<%end if%>
		<%else%>
			<td width="60%" colspan="3" ><input type="text" name=TxtTukhoa size=55 maxLength=100 style='font-family:Arial'></td>
			<td width="25%" align=right>
				<Button name="CmdOK" disabled style="font-family: Arial;width:70"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
				<Button name="CmdOK" style="font-family: Arial;width:70" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
		<%end if
	end if%>
  </tr>  
  </table>
<!-- Quy dinh quyen, noi dung van ban -->
  <table border="0" cellspacing="1" style="font-size:12pt;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0" cellpadding="1">
<tr>
	<td width="50%" colspan="2" align="center" bgcolor="#000080">
    <font color="#FFFFFF"><b>Quy định quyền văn bản</b></font></td>
	<td width="25%" align="center" bgcolor="#000080"><font color="#FFFFFF"><b>Nội dung văn bản</b></font></td>
	<td width="25%" align="center" bgcolor="#000080"><font color="#FFFFFF"><b>Chức năng</b></font></td>
</tr>
<tr>
	<td width="25%" align=center><label for=C2 accesskey="C"><u>C</u>ho phép công bố</label>
	<%	
					if bDisplay then
						if  bReadwrite then
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then %>
                                <input type=checkbox name=CheckReadwrite Checked language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%else%>
                                <input type=checkbox name=CheckReadwrite Checked disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%end if
						else
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
                                <input type=checkbox name=CheckReadwrite language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%else%>
                                <input type=checkbox name=CheckReadwrite disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%end if
						end if
					else
						if bComm<>"add" then
							if  bReadwrite then
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
                                    <input type=checkbox name=CheckReadwrite Checked language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%else%>
                                    <input type=checkbox name=CheckReadwrite Checked disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if
							else
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
                                    <input type=checkbox name=CheckReadwrite language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%else%>
                                    <input type=checkbox name=CheckReadwrite disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if
							end if
						else
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
                                <input type=checkbox name=CheckReadwrite language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%else%>
                                <input type=checkbox name=CheckReadwrite disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%end if			
						end if
					end if
				%>
				<%  if bDisplay then
						if  bReadwrite then%>
							<td width="25%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
						<%else
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
								<td width="25%"><Button name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()' accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
							<%else%>
								<td width="25%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
							<%end if
						end if
					else
						if bComm<>"add" then
							if  bReadwrite then%>
								<td width="25%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
							<%else
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
									<td width="25%"><Button name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%else%>
									<td width="25%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%end if
							end if
						else
							if bComm="add" then							
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
									<td width="25%"><Button disabled  name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%else%>
									<td width="25%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%end if
							else
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
									<td width="25%"><Button name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%else%>
									<td width="25%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>	
								<%end if
							end if
						end if
					end if%>
	<%if bComm="add" then%>
	<td width="25%"><Button disabled name="CmdXemNoidung" style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdXemNoidung_onclick()" accesskey="X"><p><u>X</u>em nội dung văn thư</p></Button></td>
	<%else%>
	<td width="25%"><Button name="CmdXemNoidung" style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdXemNoidung_onclick()" accesskey="X"><p><u>X</u>em nội dung văn thư</p></Button></td>
	<%end if%>	
	<td width="25%"><Button name="CmdAdd" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><p><u>T</u>hêm mới</p></Button></td>
</tr>
<tr>
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then %>
		<%if bComm="add" then%>
			<%if bTTDuyet then%>
				<td width="25%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
			<%else%>
				<td width="25%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
			<%end if%>
		<%else%>
				<%if bTTDuyet then%>
					<td width="25%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
				<%else%>
					<td width="25%" ><Button name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
				<%end if%>
		<%end if%>
	<%else%>					
		<td width="25%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
	<%end if%>		
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then%>
		<%if bTTDuyet then%>
			<td width="25%"><Button  name="CmdNotOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdNotOKDuyet_onclick()" accesskey="H"><p><u>H</u>ủy duyệt nội dung</p></Button></td>
		<%else%>
			<td width="25%"><Button disabled=true name="CmdNotOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdNotOKDuyet_onclick()" accesskey="H"><p><u>H</u>ủy duyệt nội dung</p></Button></td>
		<%end if%>
	<%else%>
		<td width="25%"><Button disabled=true name="CmdNotOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdNotOKDuyet_onclick()" accesskey="H"><p><u>H</u>ủy duyệt nội dung</p></Button></td>
	<%end if%>
	<%if bComm="add" then%>
		<%if bTTDuyet then%>
			<td width="25%"><Button disabled name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%else%>
			<td width="25%"><Button disabled  name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%end if%>
	<%else%>
		<%if bTTDuyet then%>
			<td width="25%"><Button disabled  name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%else%>
			<td width="25%"><Button name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%end if%>
	<%end if%>	
	<td width="25%"><Button name="CmdExit" style="font-family: Arial;width: 100%"   LANGUAGE=javascript onclick="return CmdExit_onclick()" accesskey="Y"><p>Qua<u>y</u> lại</p></Button></td>
</tr>
</table>
</form>
</body>
</html>
<Script language=vbscript runat=server>
</Script>